package com.demo.client.model.log;


import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.demo.core.annotation.TableFieldDefaultValue;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("请求日志")
@TableName(value = "sys_log")
public class SysLog {

    @ApiModelProperty("主键id")
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("标题")
    @TableFieldDefaultValue(value = "''")
    private String title;

    @ApiModelProperty("接口地址")
    @TableFieldDefaultValue(value = "''")
    private String url;

    @ApiModelProperty("请求ip")
    @TableFieldDefaultValue(value = "''")
    private String ip;

    @ApiModelProperty("请求人")
    private Long userId;

    @ApiModelProperty("1公共接口 2 鉴权接口")
    private Integer type;

    @ApiModelProperty("请求参数")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Object requestParam;

    @ApiModelProperty("模块名称")
    @TableFieldDefaultValue(value = "''")
    private String moduleName;

    @ApiModelProperty("请求方式")
    @TableFieldDefaultValue(value = "''")
    private String methodType;

    @ApiModelProperty("耗费时间")
    @TableFieldDefaultValue(value = "0")
    private Long times;

    @ApiModelProperty("响应code")
    private Integer code;

    @ApiModelProperty("错误原因")
    private String errorMsg;

    @ApiModelProperty("创建时间")
    @TableFieldDefaultValue(value = "CURRENT_TIMESTAMP")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    @ApiModelProperty("修改时间")
    @TableFieldDefaultValue(value = "CURRENT_TIMESTAMP")
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime updateTime;


}
